// JavaScript Document

function Menu(menuBarId, defaultCategory) {
	this.menuBar;
	this.icons;
	this.tipBar;
	this.currentCategory;
	
	Menu.prototype.initMenu = function() {
		this.menuBar = document.getElementById(menuBarId);
		this.icons = this.menuBar.children[0].children;
		this.tipBar = this.menuBar.children[1];
		this.currentCategory = undefined;
		for(var i=0; i< this.icons.length; ++i) {
			this.icons[i].setAttribute("onmouseover", menuBarId+".showMenuTip(this);");
			this.icons[i].setAttribute("onmouseout", menuBarId+".hideMenuTip();");
			this.icons[i].setAttribute("onclick", menuBarId+".goToCategory(this);");
			this.icons[i].setAttribute("href", "#");
		}
		this.goToCategory(this.icons[defaultCategory != null ? defaultCategory : 0]);
	};
	
	Menu.prototype.showMenuTip = function(icon) {
		this.tipBar.innerHTML = icon.children[0].innerHTML;
		this.tipBar.style.display = "block";
	};
	
	Menu.prototype.hideMenuTip = function() {
		this.tipBar.style.display = "none";
	};
	
	Menu.prototype.goToCategory = function(icon) {
		if(this.currentCategory != undefined) {
			this.currentCategory.className = this.currentCategory.className.replace("Down", "Up");
		}
		this.currentCategory = icon;
		this.currentCategory.className = this.currentCategory.className.replace("Up", "Down");
	};
	
	this.initMenu();
}